{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3abc125e",
   "metadata": {},
   "source": [
    "## FPF calibration\n",
    "Guide user towards what would be an appropriate FPF value to help ensure that targets get met. \n",
    "This step is connected to The unmet target workflow (it only increaes the fpf value of the features that have not been met)\n",
    "Similar to the BLM calibration, the steps include:\n",
    "\n",
    "1. Run the same scenario 6 times, 10 runs each, modifying the FPF value multiplied by a fixed range: 1,2,5,10,20,50,100\n",
    "2. Retrieve best solution file from each scenario\n",
    "4. Calculate the optimum FPF value that minimizes the missed targets\n",
    "\n",
    "REQUIREMENTS:\n",
    "- dict of unmet features (we could think of increasing all FPF values, so it could be used before running marxan)--> output of running the unmet workflow\n",
    "- output_mvbest.csv (Columns 'Target' and 'Misslevel')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2c075fe9",
   "metadata": {},
   "outputs": [],
   "source": [
    "%run marxan_utils.ipynb "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5c5abd8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "def createFpfProject(MARXAN_FOLDER: str, MARXAN_INPUTDATA:str, unmet_dict: dict) -> list:\n",
    "    \n",
    "    ### RUN MARXAN several times\n",
    "    fpf_range= [1,2,5,10,20,50,100]\n",
    "    fpf_folder=[]\n",
    "\n",
    "    for fpf in fpf_range:\n",
    "        print(f'\\033[1m --> Running FPF_{fpf}...\\033[0m')\n",
    "        \n",
    "        ## Create a folder for each FPF run at the same level as the original folder, \n",
    "        ## remove  folder if there is a previous one\n",
    "        ## copy all  files except outputs\n",
    "        if os.path.exists(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}'):\n",
    "            rmtree(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}')\n",
    "        copytree(MARXAN_FOLDER, f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}',ignore=ignore_patterns('output_*'))\n",
    "        \n",
    "            \n",
    "        ## Read input files\n",
    "        userInputFile = readInput(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}', MARXAN_INPUTDATA)\n",
    "        userInputFile.NUMREPS = 10\n",
    "        userInputFile.VERBOSITY = 0\n",
    "        saveInput(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}', MARXAN_INPUTDATA,userInputFile)\n",
    "        \n",
    "        spec = validateFile(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}',MARXAN_INPUTDATA, conservationFeature)\n",
    "        \n",
    "        unmet = list(unmet_dict.keys())\n",
    "        for feature in unmet:\n",
    "            spec.loc[spec['id'] == feature,'spf'] = (spec[spec['id'] == feature].spf)*fpf\n",
    "        CreateFileFromDF(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}/{userInputFile.INPUTDIR}/{userInputFile.SPECNAME}',spec, conservationFeature) \n",
    "        \n",
    "        if not os.path.exists(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}/{userInputFile.OUTPUTDIR}'):\n",
    "            os.mkdir(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}/{userInputFile.OUTPUTDIR}')\n",
    "\n",
    "        fpf_folder.append(f'FPF_{fpf}')\n",
    "        os.chmod(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}/marxan', 0o755)\n",
    "        execute_marxan(f'{os.path.dirname(MARXAN_FOLDER)}/FPF_{fpf}')\n",
    "    \n",
    "    return fpf_folder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "60e5d666",
   "metadata": {},
   "outputs": [],
   "source": [
    "def FPF_calibration(MARXAN_FOLDER: str, MARXAN_INPUTDATA :str, unmet_dict: dict, Plot: bool = True)-> float:\n",
    "    fpf_df =pd.DataFrame(columns=['folder','multiplier','missed_targets'])\n",
    "    fpf_folder = createFpfProject(MARXAN_FOLDER, MARXAN_INPUTDATA, unmet_dict)\n",
    "    fpf_df['folder'] = fpf_folder\n",
    "    fpf_df['multiplier']= [int(i.split('_')[1]) for i in fpf_folder]\n",
    "\n",
    "    for fpf in fpf_folder:\n",
    "        # using mvbest\n",
    "        mvbest = validateFile(f'{os.path.dirname(MARXAN_FOLDER)}/{fpf}',MARXAN_INPUTDATA, OutputMV)\n",
    "        fpf_df.loc[fpf_df['folder']==fpf,'missed_targets']= len(mvbest[mvbest['Target_Met'] == 'no'])\n",
    "        \n",
    "        # using an average of all the runs\n",
    "        # summary = validateFile(f'{os.path.dirname(MARXAN_FOLDER)}/{fpf}',MARXAN_INPUTDATA, OutputSum)\n",
    "        # fpf_df.loc[blm_df['folder']==fpf,'missed_targets']= summary['Missing_Values'].mean()\n",
    "    \n",
    "    ###Curve with no fit\n",
    "    y = fpf_df['missed_targets']\n",
    "    x = fpf_df['multiplier']\n",
    "\n",
    "    best_fpf = fpf_df.loc[fpf_df['missed_targets'] == min(fpf_df.missed_targets),'multiplier'].values[0]\n",
    "    \n",
    "    if Plot==True:\n",
    "        fig = plt.figure(figsize=(5,5))\n",
    "        plt.xlabel('FPF multiplier')\n",
    "        plt.ylabel('Missed targets')\n",
    "        plt.plot(x, y, 'bo-')\n",
    "    print(f'the lowest fpf that minimizes missed targets is = {best_fpf}')    \n",
    "    return best_fpf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ef4ba63c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#MARXAN_FOLDER = '/home/jovyan/work/datasets/raw/demo_marxan_okavango/Marxan_okavango_v5'\n",
    "MARXAN_FOLDER = '/home/jovyan/work/datasets/raw/demo_Coral_Triangle/marxan_Coral_Triangle_Case_Study'\n",
    "MARXAN_INPUTDATA = 'input.dat'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "c0527946",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "inputDatFile(VERSION='0.1', BLM=0.0, PROP=0.5, RANDSEED=-1, NUMREPS=100, BESTSCORE=10, NUMITNS=1000000, STARTTEMP=-1, COOLFAC=6, NUMTEMP=10000, COSTTHRESH=0.0, THRESHPEN1=14.0, THRESHPEN2=1.0, INPUTDIR='input', SPECNAME='spec.dat', PUNAME='pu.dat', PUVSPRNAME='puvspr.dat', BOUNDNAME='boundary.dat', BLOCKDEFNAME='blockdef.dat', VERBOSITY=0, MISSLEVEL=1.0, OUTPUTDIR='output', SCENNAME='output', SAVERUN=3, SAVEBEST=3, SAVESUMMARY=3, SAVESCEN=3, SAVETARGMET=3, SAVESUMSOLN=3, SAVELOG=2, SAVESNAPSTEPS=0, SAVESNAPCHANGES=0, SAVESNAPFREQUENCY=0, SAVESOLUTIONSMATRIX=3, RUNMODE=1, ITIMPTYPE=0, HEURTYPE=-1, CLUMPTYPE=0)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "userInputFile = readInput(MARXAN_FOLDER, MARXAN_INPUTDATA)\n",
    "userInputFile"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ff49b36",
   "metadata": {},
   "source": [
    "### First run unmet targets pipeline to detect features misisng"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "00b8488c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1: 'Close to target (1% away of misslevel)',\n",
       " 2: 'Close to target (1% away of misslevel)',\n",
       " 5: 'Close to target (1% away of misslevel)',\n",
       " 6: 'Close to target (1% away of misslevel)',\n",
       " 7: 'Close to target (1% away of misslevel)',\n",
       " 9: 'Close to target (1% away of misslevel)'}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "unmet_dict = unmetDecisionTree(MARXAN_FOLDER, MARXAN_INPUTDATA,\n",
    "                      lock_out_limit=0.5, \n",
    "                      high_cost_quantile= 0.7, \n",
    "                      hcost_limit=0.2)\n",
    "unmet_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "14a009cd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1m --> Running FPF_1...\u001b[0m\n",
      "Marxan v 4.0.5\n",
      "\n",
      "Spatial Prioritization via Annealing\n",
      "\n",
      "Coded by Ian Ball, modified by Matthew Watts\n",
      "Written by Ian Ball and Hugh Possingham\n",
      "\n",
      "Marxan website\n",
      "\n",
      "https://marxansolutions.org/\n",
      "\n",
      "Running multithreaded over number of threads: 4\n",
      "\n",
      "Best run: 1 Best score: 3.89587e+07\n",
      "\u001b[1m --> Running FPF_2...\u001b[0m\n",
      "Marxan v 4.0.5\n",
      "\n",
      "Spatial Prioritization via Annealing\n",
      "\n",
      "Coded by Ian Ball, modified by Matthew Watts\n",
      "\u001b[1m --> Running FPF_5...\u001b[0m\n",
      "Marxan v 4.0.5\n",
      "\n",
      "Spatial Prioritization via Annealing\n",
      "\n",
      "Coded by Ian Ball, modified by Matthew Watts\n",
      "Written by Ian Ball and Hugh Possingham\n",
      "\n",
      "Marxan website\n",
      "\n",
      "https://marxansolutions.org/\n",
      "\n",
      "Running multithreaded over number of threads: 4\n",
      "\n",
      "Best run: 1 Best score: 4.07436e+07\n",
      "\u001b[1m --> Running FPF_10...\u001b[0m\n",
      "Marxan v 4.0.5\n",
      "\n",
      "Spatial Prioritization via Annealing\n",
      "\n",
      "Coded by Ian Ball, modified by Matthew Watts\n",
      "Written by Ian Ball and Hugh Possingham\n",
      "\n",
      "Marxan website\n",
      "\n",
      "https://marxansolutions.org/\n",
      "\n",
      "Running multithreaded over number of threads: 4\n",
      "\n",
      "Best run: 9 Best score: 4.18247e+07\n",
      "\u001b[1m --> Running FPF_20...\u001b[0m\n",
      "Marxan v 4.0.5\n",
      "\n",
      "Spatial Prioritization via Annealing\n",
      "\n",
      "Coded by Ian Ball, modified by Matthew Watts\n",
      "Written by Ian Ball and Hugh Possingham\n",
      "\n",
      "Marxan website\n",
      "\n",
      "https://marxansolutions.org/\n",
      "\n",
      "Running multithreaded over number of threads: 4\n",
      "\n",
      "Best run: 4 Best score: 4.16345e+07\n",
      "\u001b[1m --> Running FPF_50...\u001b[0m\n",
      "Marxan v 4.0.5\n",
      "\n",
      "Spatial Prioritization via Annealing\n",
      "\n",
      "Coded by Ian Ball, modified by Matthew Watts\n",
      "Written by Ian Ball and Hugh Possingham\n",
      "\n",
      "Marxan website\n",
      "\n",
      "https://marxansolutions.org/\n",
      "\n",
      "Running multithreaded over number of threads: 4\n",
      "\n",
      "Best run: 3 Best score: 4.23122e+07\n",
      "\u001b[1m --> Running FPF_100...\u001b[0m\n",
      "Marxan v 4.0.5\n",
      "\n",
      "Spatial Prioritization via Annealing\n",
      "\n",
      "Coded by Ian Ball, modified by Matthew Watts\n",
      "Written by Ian Ball and Hugh Possingham\n",
      "\n",
      "Marxan website\n",
      "\n",
      "https://marxansolutions.org/\n",
      "\n",
      "Running multithreaded over number of threads: 4\n",
      "\n",
      "Best run: 5 Best score: 4.26239e+07\n",
      "the lowest fpf that minimizes missed targets is = 20\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVAAAAE9CAYAAABdgjpdAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAlI0lEQVR4nO3deZgc9X3n8fdH0kigAxBodMwIIWITr8Frrnk4jBODrwhsByfxZiEyjrPxoxw4tlmvvdhK7OCEXPZ6YxtsojUYOwjYJAabdTg3iwHHgSBhGRACI3PqFoclgTh0fPePqraaoXumuqdquqr783qefnr6V9XVv54RH76/ql9VKSIwM7PWTeh0B8zMqsoBambWJgeomVmbHKBmZm1ygJqZtckBambWpkmd7kCeZs2aFQsXLux0N8ysy6xcufKpiOgf3t5VAbpw4UJWrFjR6W6YWZeR9Hijdg/hzcza5AA1M2uTA9TMrE0OUDOzNjlAzcza5AA1M2uTA9TMrE2FBaik/ST9u6QfS1ot6YIG60jSlyWtlXSvpOPqli2S9FC67Pw8+7Z8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5Kc3veJiDgmIn7aYLXtEXECcBHJFaUaSkP7K8D7IuJ44DLgwrpVDoqIt0TE/8jSNysnD+GtE141hE/9kqQfkVzi7q8iYrWkU8k2hL8hInZJuo/kIsA3pu33kVwfMi9X1T3/zxHWex3wBuCW5JRyJpKcYljzv3Psk3WIA9TKZCz7Ol8CiIi9knbFvnOU97Lv3/lu9o269mvzc6LJz8MJWB0RJzdZ/nybn28l4iG89ZLHgOPTn3+jyTo7gBkjbOM/1z3/2wjrPQT0SzoZkiG9pKOyd9WqwAFqveQC4EuS7gD2NFnnauAT6XSqRgexpki6i+Tgz3nNPigiXgbeB/y1pB+TXD3rTWPpvJWPr8ZkllF6AeihiHiq032xcnAFambWJlegZmZtcgVqZtYmB6iZWZscoGZmbXKAmpm1yQFqZtYmB6iZWZv+P4ojJ00DzQrcAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "best_multiplier = FPF_calibration(f'{MARXAN_FOLDER}',MARXAN_INPUTDATA, unmet_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "66513a3e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
